$(function(){
	$(".dialog-wrap").hide();
	$("input[name='positionCategory']").click(function(){
		$(".dialog-wrap").show();
		$("body").attr("class","page-single dialog-open");
	});
	
	$(".icon-close").click(function(){
		$(".dialog-wrap").hide();
		$("body").attr("class","page-single");
	});
	$(".type>li").click(function(){
		$(".type>li").attr("class","none");
		$(this).attr("class","active");
	});
	$("input[name='locationName']").blur(function(){
		$(".city1").hide();
	})
	$("input[name='locationName']").click(function(){
		$(".city1").show();
	});
	$(".city1_1>li").hover(function(){
		$(this).siblings().attr("class","none");
		$(this).attr("class","cur");
	});

	$("input[name='address']").click(function(e){
        $("input[name='location1']").val("");
        $("input[name='location2']").val("");
		e.stopPropagation();
		var $address = $(".dropdown-location").attr("class");
		if($address == "dropdown-wrap dropdown-location"){
			$(".dropdown-location").attr("class","dropdown-wrap dropdown-location dropdown-menu-open");
		}else{
			$(".dropdown-location").attr("class","dropdown-wrap dropdown-location");
		}
	});
	$(document).click(function(e){
			var $select = $(".add_dress");
			//判断事件对象不是弹窗对象  并且  弹窗对象不包含事件对象
			if (!$select.is(e.target) && $select.has(e.target).length == 0) {
				$(".dropdown-location").attr("class","dropdown-wrap dropdown-location");
			}
	});
	$(".add_dress").on("click",function(){
		$(".dialog-position-manage").show();
	});
	$("span[ka='dialog_cancel']").click(function(){
		$(".dialog-position-manage").hide();
	});
	$("a[ka='dialog_close']").click(function(){
		$(".dialog-position-manage").hide();
	});
	

	
	$("input[ka='job-edit-experience']").click(function(e){
	    // $("")
		e.stopPropagation();
		var $suffer1 = $("#suffer1");
		var $suffer1class=$suffer1.attr("class");
		if($suffer1class == "dropdown-wrap dropdown-short"){
			$suffer1.attr("class","dropdown-wrap dropdown-short dropdown-menu-open");
			$("#suffer1").show();
		}else{
			$suffer1.attr("class","dropdown-wrap dropdown-short");
		}

	});
	
	$("#suffer1>ul>li").on("click",function(){
		$("input[ka='job-edit-experience']").val($(this).text());
		$("input[name='experience']").val($(this).attr("data-val"));
		$("#suffer1").css("display","none");
		// alert($(this).attr("data-val"));
	});
	$("input[ka='job-edit-experience']").click(function () {
			if($("#suffer1").is(":hidden")){
				$("#suffer1").css("display","block");
			}else{
				$("#suffer1").css("display","none");
			}
	});
	
	$("input[ka='job-edit-degree']").click(function(e){
		e.stopPropagation();
		var $suffer1 = $("#suffer2").parent();
		var $suffer1class=$suffer1.attr("class");
		if($suffer1class == "dropdown-wrap dropdown-short"){
			$suffer1.attr("class","dropdown-wrap dropdown-short dropdown-menu-open");
			// $("#suffer2").show();
		}else{
			$suffer1.attr("class","dropdown-wrap dropdown-short");
		}

	});
	$("#suffer2>ul>li").on("click",function(){
		$("input[ka='job-edit-degree']").val($(this).text());
		// $("input[name=''")
		$("#suffer2").parent().attr("class","dropdown-wrap dropdown-short");
		$("input[name='degree']").val($(this).attr("data-val"));
		// alert($(this).attr("data-val"));
	});
	//加载职位类
		var inde = 0;//显示编号
		var url = "/jobClassify/getAllJobClassify";//路径
		var data = "parentId=null";//功能
		$.getJSON(url,function(data){
			$(data).each(function(){//循环
			 var $li = $("<li onclick='jobclick1(this)' title='"+this.jobClassifyName+"' data-code='"+this.jobClassifyId+"' '=''>"+this.jobClassifyName+"</li>");

			$(".js-type").append($li);//追加

				});
			$(".js-type li").on("hover",function () {
				$(this).siblings("li").css("background-color","rgb(249, 250, 251)");
				$(this).css("background-color","white");
			});
//				$("tr:odd").css("background-color","aquamarine");//隔行变色
//				$("tr:eq(0)").css("background-color","aqua");//标题变色
			});
		//城市
    var url = "/addressClassify/getAllAddressClassify";
    var $ul = $("<ul class='addresc_ul1'></ul>");
    $.getJSON(url,function(data){
        $(data).each(function(){
            var $li = $("<li onclick='address(this)' class='' ka = '"+this.addressClassifyId+"'>"+this.addressClassifyName+"</li>");
            $($ul).append($li);
        });
        $(".addrsc").append($ul);
    });

    $("input[name='locationName']").click(function(){
        if($(".addrsc").is(":hidden")){
            $(".addrsc").css("display","block");
        }else{
            $(".addrsc").css("display","none");
        }
    });

    $("input[name='address']").click(function(){
        $(".city-name").text( $("input[name='locationName']").val());
    });


    $(".addyes").click(function(){
        var adds = $(".city-name").text();
        var location1 = $("input[name='location1']").val();
		var location2 = $("input[name='location2']").val();
		$("input[name='address']").val(adds+"/"+location1+"/"+location2);
		$("div[class='dialog-layer dialog-layer_1']").parent().css("display","none");
    });
    // //学历
	// var url = "/education/getAllEucation";
	// var $ul = $("<ul class=''></ul>");
	// $.getJSON(url,function(data){
	// 	$(data).each(function(){
	// 		var $li = $("<li onclick='ecuctclick(this)' data-val='"+this.educationId+"'>"+this.educationName+"</li>");
	// 		$($ul).append($li);
	// 	});
	// 	$(".degeree_suffer2").append($ul);
	// });
	// //经验
	// var url = "/workExperience/getAllWorkExperience";
	// var $ul = $("<ul class=''></ul>");
	// $.getJSON(url,function(data){
	// 	$(data).each(function(){
	// 		var $li = $("<li onclick='workclick(this)' data-val='"+this.workExperienceId+"'>"+this.workExperienceName+"</li>");
	// 		$($ul).append($li);
	// 	});
	// 	$(".expeer_suffer1").append($ul);
	// });
    //
	// $("input[name='ipt_experience_1']").click(function(){
	// 	if($(".suffer1").is(":hidden")){
	// 		$(".suffer1").css("display","block");
	// 	}else{
	// 		$(".suffer1").css("display","none");
	// 	}
	// });

    // $(".suffer1_ul li").on("click",function(){
    //     alert(this.text());
    //     // $(".ipt_experience_1").val(this.text());
    //     $(".suffer1").css("display","none");
    // });
	// $(".degree1").click(function(){
	// 	if($(".degeree_suffer2").is(":hidden")){
	// 		$(".degeree_suffer2").css("display","block");
	// 	}else{
	// 		$(".degeree_suffer2").css("display","none");
	// 	}
	// });

	var url = "/jobClassify/addYesOrNo";//路径
	$.getJSON(url,function(data){
		alert(123);
		if(data !=null){
			if(data == true){
				alert("添加成功!");
			}else{
				alert("添加失败!");
			}
		}
	});

})
// function workclick(data1){
// 	var workinfo = $(data1).text();
// 	$(".degree1").val(workinfo);
// }
// function ecuctclick(data1){
// 	var ecutinfo = $(data1).text();
// 	$(".degree1").val(ecutinfo);
// }
//职位第一级
function jobclick1(data1){
	// $(data1).on("click",function(){
	$(data1).siblings("li").css("background-color","rgb(249, 250, 251)");
	$(data1).css("background-color","white");
		var parId = $(data1).attr("data-code");
		var url = "/jobClassify/getAllJobClassify";//路径
		var data = {"parentId":parId};//功能
		var $div_ul = $("<div class='js-two'><ul class='navs' data-eq='"+parId+"'</ul></div>")
		$.getJSON(url,data,function(data){
			$(data).each(function(){//循环
				var $li = $("<li onclick='jobclick2(this)' class='js-li job_2li' data-code='"+this.jobClassifyId+"'>"+this.jobClassifyName+"</li>");
				$($div_ul).append($li);//追加
			});
			$(".js-content").html($div_ul);
		});
}


//职位第二级
function jobclick2(data2){
    $(".job_3").remove();
    $(data2).siblings("li").css("background-color","white");
    $(data2).css("background-color","rgba(158, 230, 222,0.9)");
    var parId = $(data2).attr("data-code");
    var url = "/jobClassify/getAllJobClassify";
    var data = {"parentId":parId};
    var $ul = $("<ul class = 'job_3' data-eq='"+parId+"'></ul>");
    $.getJSON(url,data,function(data){
        $(data).each(function(){
            var $li = $("<li onclick='jobclick3(this)' data-code='"+this.jobClassifyId+"'>"+this.jobClassifyName+"</li>");
            $($ul).append($li);
        });
        $(data2).append($ul);
    });
}
// 职位第三级
function jobclick3(data3){
  var texts = $(data3).html();
  var jobId = $(data3).attr("data-code");
  $("input[name='position']").val(jobId);
  $("input[name='positionCategory']").val(texts);
    $(".posititonss1").css("display","none");
}
//城市第二级
function address(data1){
    $(data1).siblings().css("background-color","rgba(235, 237, 242,0.9)");
    $(data1).css("background-color","white");
    $(".addresc_ul1+ ul").remove();
    var parId = $(data1).attr("ka");
    var url = "/addressClassify/getAllAddressClassify";
    var data = {"parentId":parId};
    var $ul = $("<ul class='addresc_ul2'></ul>");
    $.getJSON(url,data,function(data){
       $(data).each(function(){
           var $li = $("<li onclick='addressyes(this)' ka='"+this.addressClassifyId+"' data-val='"+this.parentId+"'>"+this.addressClassifyName+"</li>");
           $($ul).append($li);
       });
    });
    $(".addresc_ul1").after($ul);
}

function addressyes(data1){
    var address = $(data1).text();
    var addressId = $(data1).attr("ka");
    $("input[name='locationCode']").val(addressId);
    $("input[name='locationName']").val(address);

    $(".addrsc").css("display","none");
}